package Internect;
import java.util.Scanner;
public class TestInternect {

        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            UserManager userManager = new UserManager();
            AdminManager adminManager = new AdminManager();
            MemberManager memberManager = new MemberManager();

            while (true) {
                // 用户登录
                System.out.print("Username: ");
                String username = scanner.nextLine();
                System.out.print("Password: ");
                String password = scanner.nextLine();

                if (userManager.login(username, password)) {
                    System.out.println("Login successful.");

                    while (true) {
                        // 用户菜单
                        System.out.println("1. View all members");
                        System.out.println("2. Find member");
                        System.out.println("3. View cancellation records");
                        System.out.println("4. Add member");
                        System.out.println("5. Delete member");
                        System.out.println("6. Modify member information");
                        System.out.println("7. Modify user information");
                        System.out.println("8. Logout");

                        System.out.print("Choose a function: ");
                        int choice = scanner.nextInt();
                        scanner.nextLine();

                        if (choice == 1) {
                            // 查找所有会员信息
                            adminManager.findAllMembers();
                        } else if (choice == 2) {
                            // 查找会员
                            System.out.print("Enter member name: ");
                            String name = scanner.nextLine();
                            adminManager.findMember(name);
                        } else if (choice == 3) {
                            // 查看会员注销记录
                            adminManager.viewCancellationRecords();
                        } else if (choice == 4) {
                            // 添加会员
                            System.out.print("Enter member name: ");
                            String name = scanner.nextLine();
                            System.out.print("Enter member password: ");
                            String password2 = scanner.nextLine();
                            System.out.print("Enter member email: ");
                            String email = scanner.nextLine();
                            memberManager.addMember(name, password2, email);
                        } else if (choice == 5) {
                            // 删除会员
                            System.out.print("Enter member name: ");
                            String name = scanner.nextLine();
                            memberManager.deleteMember(name);
                        } else if (choice == 6) {
                            // 修改会员信息
                            System.out.print("Enter member name: ");
                            String name = scanner.nextLine();
                            System.out.print("Enter member password: ");
                            String password2 = scanner.nextLine();
                            System.out.print("Enter member email: ");
                            String email = scanner.nextLine();
                            memberManager.modifyMember(name, password2, email);
                        } else if (choice == 7) {
                            // 修改用户信息
                            System.out.print("Enter new username: ");
                            String newUsername = scanner.nextLine();
                            System.out.print("Enter new password: ");
                            String newPassword = scanner.nextLine();
                            userManager.modify(username, password, newUsername, newPassword);
                            username = newUsername;
                            password = newPassword;
                        } else if (choice == 8) {
                            // 用户退出
                            userManager.logout();
                        } else {
                            System.out.println("Invalid choice.");
                        }
                    }
                } else {
                    System.out.println("Login failed. Please try again.");
                }
            }
        }
}
